#include "utils/str_utils.hpp"

void trim_left (std::string &s)
{
    s.erase(s.begin(), std::ranges::find_if(s, [](unsigned char ch) {
        return !std::isspace(ch);
    }));
}

void trim_right (std::string &s)
{
    s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
        return !std::isspace(ch);
    }).base(), s.end());
}

void trim (std::string &s)
{
    trim_left(s);
    trim_right(s);
}

std::string trim_left_copy (std::string s)
{
    trim_left(s);
    return s;
}

std::string trim_right_copy (std::string s)
{
    trim_right(s);
    return s;
}

std::string trim_copy (std::string s)
{
    trim(s);
    return s;
}
